package com.example.tbplus14.Test;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;


public class CompletableFutureThreadPool {

    final int poolSize = Runtime.getRuntime().availableProcessors();

    public ThreadPoolExecutor poolExecutor() {
        return poolExecutor(5000);
    }

    public ThreadPoolExecutor poolExecutor(int capacity) {
        return new ThreadPoolExecutor(
                poolSize,
                40,
                60L,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(capacity));
    }
}
